package com.sap.sap_mangers.Vo.SawbsVo;

import com.sap.sap_mangers.pojo.DetailsUser;
import com.sap.sap_mangers.pojo.DynamicMessage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author 樊东升
 * @date 2022/7/31 19:17
 * 获取学习小组学习情况的视图类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SawbsMessageVo implements Comparable<SawbsMessageVo> {
    private String username;
    private String name;
    private Integer week;
    private Integer note;
    private Integer summary;
    private Integer depth;
    private Integer enthusiasm;
    private Integer comprehensive;
    private String desc;
    private Integer year;
    private Integer order;
    //负责人的学号
    private String managerName;

    private Integer rank;
    private Integer sumPeople;
    private Integer sumScore;
    /**
     * 被负责人的列表
     */
    private List<DetailsUser> managerUsers;

    private List<SawbsMessageVo> userScore;

    /**
     * 给学习信息设置默认的时间
     *
     * @param dynamicMessage 动态表的时间信息
     */
    public void setDefaultTimeByDynamicTable(DynamicMessage dynamicMessage) {
        //规定 年 必须依照动态表
        year = dynamicMessage.getYear();
        if (week == null || week <= 0) {
            week = dynamicMessage.getWeek();
        }
        if (order == null || order <= 0) {
            order = dynamicMessage.getOrder();
        }
    }

    /**
     * 验证字段信息是否合理
     *
     * @return 合理返回true
     */
    public boolean identityInformation() {
        return identityRange(note) || identityRange(summary) || identityRange(depth) || identityRange(enthusiasm) || identityRange(comprehensive);
    }

    /**
     * 查看范围是否正确
     *
     * @param integer 值
     * @return 正确返回true
     */
    public boolean identityRange(Integer integer) {
        return integer < 1 || integer > 5;
    }


    @Override
    public int compareTo(SawbsMessageVo o) {
        return o.getSumScore() - this.sumScore;
    }
}
